package com.shop.shoppingmall.entity;

import com.github.wxpay.sdk.WXPayConfig;

import java.io.IOException;
import java.io.InputStream;

public class MyPayConfig implements WXPayConfig {
    private TenpayConfig payConfig;
    private byte[] certData;

    public MyPayConfig(TenpayConfig config) throws IOException {
        this.payConfig = config;
//        File file = new File(payConfig.getCertPath());
//        InputStream certStream = new FileInputStream(file);
//        this.certData = new byte[(int) file.length()];
//        certStream.read(this.certData);
//        certStream.close();
    }

    @Override
    public String getAppID() {
        return payConfig.getAppId();
    }

    @Override
    public String getMchID() {
        return payConfig.getMchId();
    }

    @Override
    public String getKey() {
        return payConfig.getKey();
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

//    @Override
//    public InputStream getCertStream() {
//        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
//        return certBis;
//    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
